import { Component, OnInit } from '@angular/core'
import { ApiService } from '../../services/api.service'
import {PageService} from "@core/http";

@Component({
  selector: 'app-tag-view',
  templateUrl: './tag-view.component.html',
  styleUrls: ['./tag-view.component.scss']
})
export class TagViewComponent implements OnInit {
  public hotTagList: any[] = []
  public userTagList: any[] = []
  public newTagList: any[] = []
  constructor(private apiService: ApiService,
  public pageService:PageService
  ) {
    // this.apiService.getCustomerTagList('tag').subscribe(data => {
    //   const list = data.sort(x => 0.3 - Math.random()).slice(0, 10)
    //   this.hotTagList = list.sort(x => 0.3 - Math.random()).slice(0, 10)
    //   this.userTagList = list.sort(x => 0.4 - Math.random()).slice(0, 10)
    //   this.newTagList = list.sort(x => 0.5 - Math.random()).slice(0, 10)
    // })
  }

  ngOnInit() {
    this.getTagHot();
    this.getTagActive();
    this.getTagAdd();
  }
  //获取热门标签
  public getTagHot(){

    this.apiService.getTagHot().subscribe(list => {
      this.hotTagList = list
    })
  }
  //获取活跃标签
  public getTagActive(){
    this.apiService.getTagActive().subscribe(list => {
      this.userTagList = list
    })
  }
  public getTagAdd(){
    this.apiService.getTagAdd().subscribe(list => {
      console.log('list:'+JSON.stringify(list))
      this.pageService.total = 5
      this.newTagList = list
    })
  }
}
